package nc.vo.bd.userdefrule;

import nc.itf.bd.userdefrule.UserdefruleMultiLangName;
import nc.vo.pub.BusinessException;

public class UserdefItemUtil
{

    public UserdefItemUtil()
    {
    }

    public static int getUserdefColumnIndex(String columnName)
        throws BusinessException
    {
        if(columnName == null || columnName.length() == 0)
            throw new BusinessException((new StringBuilder()).append(UserdefruleMultiLangName.getUserdefitemName()).append("feild name is null.").toString());
        char colChars[] = columnName.toCharArray();
        System.out.println(colChars.length);
        int numberStartIndex = -1;
        for(int i = 0; i < colChars.length; i++)
        {
            char c = colChars[i];
            if(c >= '0' && c <= '9')
            {
                if(numberStartIndex == -1)
                    numberStartIndex = i;
            } else
            {
                numberStartIndex = -1;
            }
        }

        return Integer.valueOf(columnName.substring(numberStartIndex)).intValue();
    }
}